
// Open MoneySpinner Suite v1
// An open source business management software system written in Java and MySQL
// Recommended IDE is NetBeans IDE 7.0.1
// Support Web Site: http://www.milliscript.com
//
// Copyright (C) 2014, Abiodun Aremu, Ibadan/NIGERIA.
// Open MoneySpinner Suite is distributed under the terms of the Apache License version 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package openmoneyspinnersuite;

/**
 *
 * @author Abiodun Aremu
 */
import javax.swing.*;

final class ViewDebitReport extends javax.swing.JInternalFrame {

    Object[][] tableObject=new Object[][]{};
    Systems systems=new Systems();
    javax.swing.ButtonGroup jButtonGroup1=new javax.swing.ButtonGroup();
    String statementType="";
    String statementStartDate="";
    String statementEndDate="";
    String statementAccountName="";
    String statementAccountUnit="";
    String statementItemName="";
    String statementMerchantID="";
    String statementActivity="";
    String statementTransferActivityState="";
    Thread processThread=new Thread();
    Thread titleThread=new Thread();
    String currentTitle="";

    /** Creates new form ViewCredit */
    ViewDebitReport() {
        initComponents();
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
        tableObject,
            new String [] {
                "S/N", "Order By", "Order Code", "Order Date", "Debit Code", "Debit Date", "Amount", "Currency","Cash Outflow Activity"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        processThread=new Thread(new Runnable() {
            public void run() {
            disableControls();
            refreshTable();
            resetTransMonth();
            resetTransYear();
            resetEndMonth();
            resetEndYear();
            }
        });
        titleThread=new Thread(new Runnable() {
            public void run() {
                while(processThread.isAlive())setProcessingTitle(titleThread);
                enableControls();
                System.out.println("viewItemThread stopped runing.");
            }
        });
        processThread.start();
        titleThread.start();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jRefreshButton = new javax.swing.JButton();
        jCancelButton = new javax.swing.JButton();
        jPreviewButton = new javax.swing.JButton();
        jAccountRadioButton = new javax.swing.JRadioButton();
        jMerchantRadioButton = new javax.swing.JRadioButton();
        jMerchantIDComboBox = new javax.swing.JComboBox();
        jAccountNameComboBox = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        startMonthComboBox = new javax.swing.JComboBox();
        startDayComboBox = new javax.swing.JComboBox();
        startYearComboBox = new javax.swing.JComboBox();
        endYearComboBox = new javax.swing.JComboBox();
        jNameTextField = new javax.swing.JTextField();
        endDayComboBox = new javax.swing.JComboBox();
        endMonthComboBox = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jActivityRadioButton = new javax.swing.JRadioButton();
        jActivityComboBox = new javax.swing.JComboBox();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox2 = new javax.swing.JCheckBox();
        jItemRadioButton = new javax.swing.JRadioButton();
        jItemComboBox = new javax.swing.JComboBox();
        jUserTextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jUserIDRadioButton = new javax.swing.JRadioButton();
        jUserIDComboBox = new javax.swing.JComboBox();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(openmoneyspinnersuite.OpenMS_Finance_App.class).getContext().getResourceMap(ViewDebitReport.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N
        setName("Form"); // NOI18N
        setVisible(true);

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null}
            },
            new String [] {
                "S/N", "Order By", "Order Code", "Order Date", "Credit Code", "Credit Date", "Amount", "Currency"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setName("jTable1"); // NOI18N
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(10);
        jTable1.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("jTable1.columnModel.title0")); // NOI18N
        jTable1.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("jTable1.columnModel.title1")); // NOI18N
        jTable1.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("jTable1.columnModel.title2")); // NOI18N
        jTable1.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("jTable1.columnModel.title3")); // NOI18N
        jTable1.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("jTable1.columnModel.title4")); // NOI18N
        jTable1.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("jTable1.columnModel.title5")); // NOI18N
        jTable1.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("jTable1.columnModel.title6")); // NOI18N
        jTable1.getColumnModel().getColumn(7).setHeaderValue(resourceMap.getString("jTable1.columnModel.title7")); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        jRefreshButton.setFont(resourceMap.getFont("jRefreshButton.font")); // NOI18N
        jRefreshButton.setIcon(resourceMap.getIcon("jRefreshButton.icon")); // NOI18N
        jRefreshButton.setText(resourceMap.getString("jRefreshButton.text")); // NOI18N
        jRefreshButton.setName("jRefreshButton"); // NOI18N
        jRefreshButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRefreshButtonActionPerformed(evt);
            }
        });

        jCancelButton.setFont(resourceMap.getFont("jCancelButton.font")); // NOI18N
        jCancelButton.setIcon(resourceMap.getIcon("jCancelButton.icon")); // NOI18N
        jCancelButton.setText(resourceMap.getString("jCancelButton.text")); // NOI18N
        jCancelButton.setName("jCancelButton"); // NOI18N
        jCancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCancelButtonActionPerformed(evt);
            }
        });

        jPreviewButton.setText(resourceMap.getString("jPreviewButton.text")); // NOI18N
        jPreviewButton.setName("jPreviewButton"); // NOI18N
        jPreviewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPreviewButtonActionPerformed(evt);
            }
        });

        jButtonGroup1.add(jAccountRadioButton);
        jAccountRadioButton.setText(resourceMap.getString("jAccountRadioButton.text")); // NOI18N
        jAccountRadioButton.setName("jAccountRadioButton"); // NOI18N
        jAccountRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jAccountRadioButtonActionPerformed(evt);
            }
        });

        jButtonGroup1.add(jMerchantRadioButton);
        jMerchantRadioButton.setText(resourceMap.getString("jMerchantRadioButton.text")); // NOI18N
        jMerchantRadioButton.setName("jMerchantRadioButton"); // NOI18N
        jMerchantRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMerchantRadioButtonActionPerformed(evt);
            }
        });

        jMerchantIDComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Merchant ID --" }));
        jMerchantIDComboBox.setEnabled(false);
        jMerchantIDComboBox.setName("jMerchantIDComboBox"); // NOI18N
        jMerchantIDComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMerchantIDComboBoxActionPerformed(evt);
            }
        });

        jAccountNameComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Account Name --" }));
        jAccountNameComboBox.setEnabled(false);
        jAccountNameComboBox.setName("jAccountNameComboBox"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        startMonthComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Month --" }));
        startMonthComboBox.setName("startMonthComboBox"); // NOI18N
        startMonthComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startMonthComboBoxActionPerformed(evt);
            }
        });

        startDayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Day --" }));
        startDayComboBox.setName("startDayComboBox"); // NOI18N

        startYearComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Year --" }));
        startYearComboBox.setName("startYearComboBox"); // NOI18N

        endYearComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Year --" }));
        endYearComboBox.setName("endYearComboBox"); // NOI18N

        jNameTextField.setEditable(false);
        jNameTextField.setName("jNameTextField"); // NOI18N
        jNameTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jNameTextFieldActionPerformed(evt);
            }
        });

        endDayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Day --" }));
        endDayComboBox.setName("endDayComboBox"); // NOI18N

        endMonthComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Month --" }));
        endMonthComboBox.setName("endMonthComboBox"); // NOI18N
        endMonthComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                endMonthComboBoxActionPerformed(evt);
            }
        });

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jButtonGroup1.add(jActivityRadioButton);
        jActivityRadioButton.setText(resourceMap.getString("jActivityRadioButton.text")); // NOI18N
        jActivityRadioButton.setName("jActivityRadioButton"); // NOI18N
        jActivityRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jActivityRadioButtonActionPerformed(evt);
            }
        });

        jActivityComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Cash Outflow Activity --", "Operating Activity", "Investing Activity", "Financing Activity", "---", "Transfer Activity" }));
        jActivityComboBox.setEnabled(false);
        jActivityComboBox.setName("jActivityComboBox"); // NOI18N
        jActivityComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jActivityComboBoxActionPerformed(evt);
            }
        });

        jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N
        jCheckBox1.setName("jCheckBox1"); // NOI18N
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });

        jCheckBox2.setText(resourceMap.getString("jCheckBox2.text")); // NOI18N
        jCheckBox2.setName("jCheckBox2"); // NOI18N
        jCheckBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox2ActionPerformed(evt);
            }
        });

        jButtonGroup1.add(jItemRadioButton);
        jItemRadioButton.setText(resourceMap.getString("jItemRadioButton.text")); // NOI18N
        jItemRadioButton.setName("jItemRadioButton"); // NOI18N
        jItemRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jItemRadioButtonActionPerformed(evt);
            }
        });

        jItemComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Item Name --", "Operating Activity", "Investing Activity", "Financing Activity", "---", "Transfer Activity" }));
        jItemComboBox.setEnabled(false);
        jItemComboBox.setName("jItemComboBox"); // NOI18N
        jItemComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jItemComboBoxActionPerformed(evt);
            }
        });

        jUserTextField.setEditable(false);
        jUserTextField.setName("jUserTextField"); // NOI18N
        jUserTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jUserTextFieldActionPerformed(evt);
            }
        });

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jButtonGroup1.add(jUserIDRadioButton);
        jUserIDRadioButton.setText(resourceMap.getString("jUserIDRadioButton.text")); // NOI18N
        jUserIDRadioButton.setName("jUserIDRadioButton"); // NOI18N
        jUserIDRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jUserIDRadioButtonActionPerformed(evt);
            }
        });

        jUserIDComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- User ID --" }));
        jUserIDComboBox.setEnabled(false);
        jUserIDComboBox.setName("jUserIDComboBox"); // NOI18N
        jUserIDComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jUserIDComboBoxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCheckBox1)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jCheckBox2)
                                .addGap(48, 48, 48)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 162, Short.MAX_VALUE)
                        .addComponent(jPreviewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRefreshButton, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(205, 205, 205))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jItemRadioButton)
                            .addComponent(jMerchantRadioButton)
                            .addComponent(jAccountRadioButton)
                            .addComponent(jActivityRadioButton)
                            .addComponent(jUserIDRadioButton))
                        .addGap(8, 8, 8)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jUserIDComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jActivityComboBox, javax.swing.GroupLayout.Alignment.TRAILING, 0, 309, Short.MAX_VALUE)
                                .addComponent(jMerchantIDComboBox, javax.swing.GroupLayout.Alignment.TRAILING, 0, 309, Short.MAX_VALUE)
                                .addComponent(jAccountNameComboBox, javax.swing.GroupLayout.Alignment.TRAILING, 0, 309, Short.MAX_VALUE)
                                .addComponent(jItemComboBox, 0, 309, Short.MAX_VALUE)))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addGap(109, 109, 109)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(startMonthComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(startDayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(startYearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel4)
                                            .addComponent(jLabel9))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(endMonthComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(endDayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(endYearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addComponent(jNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jUserTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jMerchantRadioButton)
                        .addGap(25, 25, 25))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(startMonthComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(startDayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(startYearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(endMonthComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(endDayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(endYearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jAccountNameComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jAccountRadioButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jMerchantIDComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jActivityComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jActivityRadioButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jUserTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(6, 6, 6)
                                .addComponent(jItemComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jUserIDComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jUserIDRadioButton)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jItemRadioButton)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 62, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jCancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jRefreshButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPreviewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jCheckBox1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox2)
                        .addContainerGap())))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 931, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jRefreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRefreshButtonActionPerformed

        processThread=new Thread(new Runnable() {
            public void run() {
            disableControls();
            refreshTable();
            }
        });
        titleThread=new Thread(new Runnable() {
            public void run() {
                while(processThread.isAlive())setProcessingTitle(titleThread);
                enableControls();
                System.out.println("viewItemThread stopped runing.");
            }
        });
        processThread.start();
        titleThread.start();
    }//GEN-LAST:event_jRefreshButtonActionPerformed

    private void jCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCancelButtonActionPerformed

        if(processThread.isAlive())
        {
            try{
                processThread.stop();
                titleThread.stop();
                System.out.println("Threads successfully stopped.");
            }catch(Exception e){System.out.println("Thread stopping error: "+e);}
            this.setTitle("::. View Debit Report");
            enableControls();
        }
        else
        dispose();
    }//GEN-LAST:event_jCancelButtonActionPerformed
    void resetCombo()
    {
        resetAccountName();
        resetMerchantName();
        resetItemName();
        resetTransMonth();
        resetTransDay("");
        resetTransYear();
        resetEndMonth();
        resetEndDay("");
        resetEndYear();
        jActivityComboBox.setSelectedItem("-- Cash Outflow Activity --");
    }
    void reset()
    {
        resetAccountName();
        resetMerchantName();
        resetItemName();
        resetTransMonth();
        resetTransYear();
        resetTransDay("");
        resetEndMonth();
        resetEndDay("");
        resetEndYear();
        jNameTextField.setText("");
        jActivityComboBox.setSelectedItem("-- Cash Outflow Activity --");
        if(jCheckBox1.isSelected()){
        jCheckBox1.doClick();
        }
        if(jCheckBox2.isSelected()){
        jCheckBox2.doClick();
        }
        refreshTable();
    }
    private void jPreviewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPreviewButtonActionPerformed

        processThread=new Thread(new Runnable() {
            public void run() {
                disableControls();
                java.lang.Runtime run=java.lang.Runtime.getRuntime();
                try
                {
                    NoteWriter note=new NoteWriter();
                    note.writeDebitStatement(statementType,statementAccountName,statementAccountUnit,statementMerchantID,statementActivity,statementItemName,statementTransferActivityState,statementStartDate,statementEndDate);
                         
                    if(OpenMSApp.d==null)
                    {
                        OpenMSApp.d=new NoteViewer("Preview Debit Journal - ",Configuration.statementOfCashOutflowNotePath);
                        OpenMSApp.d.setVisible(true);
                    }
                    else if(OpenMSApp.d.isVisible()==false)
                    {
                        OpenMSApp.d=new NoteViewer("Preview Debit Journal - ",Configuration.statementOfCashOutflowNotePath);
                        OpenMSApp.d.setVisible(true);       
                    }
                    else{
                        OpenMSApp.d.setTitle("Preview Debit Journal");
                        OpenMSApp.d.doTas(OpenMSApp.d.DEBIT_JOURNAL_TABINDEX);
                        OpenMSApp.d.transferFocus();                
                    }
                }
                catch(Exception e)
                {
                    System.out.println("Error occur at ViewDebitReport.jPreviewButtonActionPerformed ! "+e);
                }
            }
        });
        titleThread=new Thread(new Runnable() {
            public void run() {
                while(processThread.isAlive())setProcessingTitle(titleThread);
                enableControls();
                System.out.println("viewItemThread stopped runing.");
            }
        });
        processThread.start();
        titleThread.start();


}//GEN-LAST:event_jPreviewButtonActionPerformed

    private void jAccountRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAccountRadioButtonActionPerformed
        // TODO add your handling code here:
        if(jAccountRadioButton.isSelected()) {
            jMerchantIDComboBox.setEnabled(false);
            jActivityComboBox.setEnabled(false);
            jItemComboBox.setEnabled(false);
            jUserIDComboBox.setEnabled(false);
            jAccountNameComboBox.setEnabled(true);
        } else {
            jAccountNameComboBox.setEnabled(false);
            jAccountNameComboBox.setSelectedItem("-- Account Name --");
        }
        resetAccountName();
        resetMerchantName();
        resetItemName();
        jActivityComboBox.setSelectedItem("-- Cash Outflow Activity --");
}//GEN-LAST:event_jAccountRadioButtonActionPerformed

    private void jMerchantRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMerchantRadioButtonActionPerformed
        // TODO add your handling code here:
        if(jMerchantRadioButton.isSelected()) {
            jMerchantIDComboBox.setEnabled(true);
            jAccountNameComboBox.setEnabled(false);
            jItemComboBox.setEnabled(false);
            jActivityComboBox.setEnabled(false);
            jUserIDComboBox.setEnabled(false);
        } else {
            jMerchantIDComboBox.setEnabled(false);
            jMerchantIDComboBox.setSelectedItem("-- Merchant ID --");
        }
        resetMerchantName();
        resetAccountName();
        resetItemName();
        jActivityComboBox.setSelectedItem("-- Cash Outflow Activity --");
}//GEN-LAST:event_jMerchantRadioButtonActionPerformed

    private void jMerchantIDComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMerchantIDComboBoxActionPerformed
        // TODO add your handling code here:
        String merchantID=jMerchantIDComboBox.getSelectedItem().toString();
        if(merchantID.equals("-- Merchant ID --")) {
            resetMerchantID();
        } else {
            jNameTextField.setText(systems.getValue(OpenMSApp.Database_A, "Select * from vwMerchant where cMerchantID = '"+merchantID+"'", "vName"));
        }
}//GEN-LAST:event_jMerchantIDComboBoxActionPerformed

    private void startMonthComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startMonthComboBoxActionPerformed
        // TODO add your handling code here:
        String transMonth=startMonthComboBox.getSelectedItem().toString();

        if(transMonth.equals("-- Month --")) {
        } else {
            resetTransDay(transMonth);
        }
}//GEN-LAST:event_startMonthComboBoxActionPerformed

    private void jNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNameTextFieldActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jNameTextFieldActionPerformed

    private void endMonthComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_endMonthComboBoxActionPerformed
        // TODO add your handling code here:
        String endMonth=endMonthComboBox.getSelectedItem().toString();

        if(endMonth.equals("-- Month --")) {
        } else {
            resetEndDay(endMonth);
        }
}//GEN-LAST:event_endMonthComboBoxActionPerformed

    private void jActivityRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jActivityRadioButtonActionPerformed
        // TODO add your handling code here:
        if(jActivityRadioButton.isSelected()) {
            jMerchantIDComboBox.setEnabled(false);
            jAccountNameComboBox.setEnabled(false);
            jItemComboBox.setEnabled(false);
            jUserIDComboBox.setEnabled(false);
            jActivityComboBox.setEnabled(true);
        } else {
            jActivityComboBox.setEnabled(false);
            jActivityComboBox.setSelectedItem("-- Cash Outflow Activity --");
        }
        resetMerchantName();
        resetAccountName();
        resetItemName();
        jActivityComboBox.setSelectedItem("-- Cash Outflow Activity --");
    }//GEN-LAST:event_jActivityRadioButtonActionPerformed

    private void jActivityComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jActivityComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jActivityComboBoxActionPerformed

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox1ActionPerformed

    private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox2ActionPerformed

    private void jItemRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jItemRadioButtonActionPerformed
        // TODO add your handling code here:
        if(jItemRadioButton.isSelected()) {
            jItemComboBox.setEnabled(true);
            jMerchantIDComboBox.setEnabled(false);
            jAccountNameComboBox.setEnabled(false);
            jActivityComboBox.setEnabled(false);
            jUserIDComboBox.setEnabled(false);
        } else {
            jItemComboBox.setEnabled(false);
            jItemComboBox.setSelectedItem("-- Item Name --");
        }
        resetMerchantName();
        resetAccountName();
        resetItemName();
        jActivityComboBox.setSelectedItem("-- Cash Outflow Activity --");
    }//GEN-LAST:event_jItemRadioButtonActionPerformed

    private void jItemComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jItemComboBoxActionPerformed
        // TODO add your handling code here:
        if(jItemComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Item Name --"))
        {
            resetItemName();
        }
    }//GEN-LAST:event_jItemComboBoxActionPerformed

private void jUserTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jUserTextFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jUserTextFieldActionPerformed

private void jUserIDRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jUserIDRadioButtonActionPerformed

        if(jUserIDRadioButton.isSelected()) {
            jUserIDComboBox.setEnabled(true);
            jActivityComboBox.setEnabled(false);
            jMerchantIDComboBox.setEnabled(false);
            jAccountNameComboBox.setEnabled(false);
        } else {
            jUserIDComboBox.setEnabled(false);
            jUserIDComboBox.setSelectedItem("-- User ID --");
        }
        resetAccountName();
        resetMerchantName();
        resetItemName();
        resetUserID();
        jActivityComboBox.setSelectedItem("-- Cash Inflow Activity --");
}//GEN-LAST:event_jUserIDRadioButtonActionPerformed

private void jUserIDComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jUserIDComboBoxActionPerformed

        if(jUserIDComboBox.getSelectedItem().toString().equals("-- User ID --")) {
            resetUserID();
        } else {
            String userID=systems.getValue(OpenMSApp.Database_A, "Select cEmployeeID from login where cLoginCode='"+jUserIDComboBox.getSelectedItem().toString()+"'",1);
            jUserTextField.setText(systems.getValue(OpenMSApp.Database_A, "Select vName from vwMerchant where cMerchantID='"+userID+"'", "vName"));
        }
}//GEN-LAST:event_jUserIDComboBoxActionPerformed
    
    void resetUserID()
    {
        String[] userID=systems.getTableDataArray(OpenMSApp.Database_A,"Login where cStatus='Active'",1);
        userID[0]="-- User ID --";

        jUserIDComboBox.setModel(new DefaultComboBoxModel(userID));
        jUserIDComboBox.setSelectedItem("-- User ID --");
    }
    private void setProcessingTitle(Thread thread)
    {
        try{
            this.setTitle("::. View Debit Report - Processing Request");
            thread.sleep(500);
            this.setTitle("::. View Debit Report - Processing Request.");
            thread.sleep(500);
            this.setTitle("::. View Debit Report - Processing Request..");
            thread.sleep(500);
            this.setTitle("::. View Debit Report - Processing Request...");
            thread.sleep(500);
        }catch(Exception e){System.out.println("Title thread"+e);}
    }
    private void disableControls()
    {
        jPreviewButton.setEnabled(false);
        jRefreshButton.setEnabled(false);
        jAccountRadioButton.setEnabled(false);
        jMerchantRadioButton.setEnabled(false);
        jActivityRadioButton.setEnabled(false);
        jAccountNameComboBox.setEnabled(false);
        jMerchantIDComboBox.setEnabled(false);
        jActivityComboBox.setEnabled(false);
        jCheckBox1.setEnabled(false);
        jCheckBox2.setEnabled(false);
        startMonthComboBox.setEnabled(false);
        startDayComboBox.setEnabled(false);
        startYearComboBox.setEnabled(false);
        endMonthComboBox.setEnabled(false);
        endDayComboBox.setEnabled(false);
        endYearComboBox.setEnabled(false);
    }
    
    private void enableControls()
    {
        jPreviewButton.setEnabled(true);
        jRefreshButton.setEnabled(true);
        jAccountRadioButton.setEnabled(true);
        jMerchantRadioButton.setEnabled(true);
        jActivityRadioButton.setEnabled(true);
        
        if(jAccountRadioButton.isSelected())
        {
            jMerchantIDComboBox.setEnabled(false);
            jActivityComboBox.setEnabled(false);
            jAccountNameComboBox.setEnabled(true);
        }
        if(jMerchantRadioButton.isSelected())
        {
            jMerchantIDComboBox.setEnabled(true);
            jAccountNameComboBox.setEnabled(false);
            jActivityComboBox.setEnabled(false);
        }
        if(jActivityRadioButton.isSelected())
        {
            jActivityComboBox.setEnabled(true);
            jMerchantIDComboBox.setEnabled(false);
            jAccountNameComboBox.setEnabled(false);
        }
        
        jCheckBox1.setEnabled(true);
        jCheckBox2.setEnabled(true);
        startMonthComboBox.setEnabled(true);
        startDayComboBox.setEnabled(true);
        startYearComboBox.setEnabled(true);
        endMonthComboBox.setEnabled(true);
        endDayComboBox.setEnabled(true);
        endYearComboBox.setEnabled(true);
        this.setTitle(currentTitle);
    }
    void print()
    {
        try
        {
            jTable1.print();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    void resetTransYear()
    {
        String[] year=systems.getYears(1920);
        year[0]="-- Year --";
        startYearComboBox.setModel(new DefaultComboBoxModel(year));
    }
    void resetTransMonth()
    {
        String[] month=systems.getMonthArray();
        month[0]="-- Month --";

        startMonthComboBox.setModel(new DefaultComboBoxModel(month));

    }
    void resetTransDay(String Month)
    {
        String[] day={"-- Day --"};
        if(Month.isEmpty())
        {
            startDayComboBox.setModel(new DefaultComboBoxModel(day));
        }
        else
        {
            day=systems.getDays(Month);
            day[0]="-- Day --";
            startDayComboBox.setModel(new DefaultComboBoxModel(day));
        }
    }

    void resetEndYear()
    {
        String[] year=systems.getYears(1920);
        year[0]="-- Year --";
        endYearComboBox.setModel(new DefaultComboBoxModel(year));
    }
    void resetEndMonth()
    {
        String[] month=systems.getMonthArray();
        month[0]="-- Month --";

        endMonthComboBox.setModel(new DefaultComboBoxModel(month));

    }
    void resetEndDay(String Month)
    {
        String[] day={"-- Day --"};
        if(Month.isEmpty())
        {
            endDayComboBox.setModel(new DefaultComboBoxModel(day));
        }
        else
        {
            day=systems.getDays(Month);
            day[0]="-- Day --";
            endDayComboBox.setModel(new DefaultComboBoxModel(day));
        }
    }

    void resetMerchantID()
    {
        String[] merchant=systems.getTableDataArray(OpenMSApp.Database_A,"vwMerchant",1);
        merchant[0]="-- Merchant ID --";

        jMerchantIDComboBox.setModel(new DefaultComboBoxModel(merchant));
        jMerchantIDComboBox.setSelectedItem("-- Merchant ID --");
        jNameTextField.setText("");
    }

    void resetMerchantName()
    {
        String[] merchantName=systems.getTableDataArray(OpenMSApp.Database_A,"vwMerchant",2);
        merchantName[0]="-- Merchant Name --";
        jMerchantIDComboBox.setModel(new javax.swing.DefaultComboBoxModel(merchantName));
        resetMerchantID();
        jNameTextField.setText("");
    }
    void resetAccountName()
    {
        String[] accountName=systems.getTableDataArray(OpenMSApp.Database_A,"Account",2);
        accountName[0]="-- Account Name --";
        jAccountNameComboBox.setModel(new javax.swing.DefaultComboBoxModel(accountName));
        jAccountNameComboBox.setSelectedItem("-- Account Name --");
    }
    void resetItemName()
    {
        String[] item=systems.getTableDataArray(OpenMSApp.Database_A,"Item",2);
        item[0]="-- Item Name --";

        jItemComboBox.setModel(new DefaultComboBoxModel(item));
        jItemComboBox.setSelectedItem("-- Item Name --");
    }
    private boolean isDateChoosen()
    {
        boolean dateChoosen=false;
        if(!startMonthComboBox.getSelectedItem().equals("-- Month --"))
        {
            dateChoosen=true;
        }
        if(!startDayComboBox.getSelectedItem().equals("-- Day --"))
        {
            dateChoosen=true;
        }
        if(!startYearComboBox.getSelectedItem().equals("-- Year --"))
        {
            dateChoosen=true;
        }
        if(!endMonthComboBox.getSelectedItem().equals("-- Month --"))
        {
            dateChoosen=true;
        }
        if(!endDayComboBox.getSelectedItem().equals("-- Day --"))
        {
            dateChoosen=true;
        }
        if(!endYearComboBox.getSelectedItem().equals("-- Year --"))
        {
            dateChoosen=true;
        }
        return dateChoosen;
    }
    private void refreshTable()
    {
        String[] dbOrderCode={};
        String[] dbAccountCode={};
        String[] dbDebitCode={};
        String[] dbPostDate={};
        String[] dbOrderBy={};
        String[] dbOrderDate={};
        String[] dbAmount={};
        String accountName_A=String.valueOf(jAccountNameComboBox.getSelectedItem());
        String merchantID_A=String.valueOf(jMerchantIDComboBox.getSelectedItem());
        String userID_A=String.valueOf(jUserIDComboBox.getSelectedItem());
        String activity_A=String.valueOf(jActivityComboBox.getSelectedItem());
        String itemName_A=String.valueOf(jItemComboBox.getSelectedItem());
        String useDate="N";
        String startDate="";
        String endDate="";

        if(jCheckBox1.isSelected()) {
            statementTransferActivityState=" and cActivity != 'Transfer Activity' ";
        } else {
            statementTransferActivityState="";
        }

        if(jActivityComboBox.getSelectedItem().toString().equalsIgnoreCase("Financing Activity")||jActivityComboBox.getSelectedItem().toString().equalsIgnoreCase("Investing Activity")||jActivityComboBox.getSelectedItem().toString().equalsIgnoreCase("Operating Activity")||jActivityComboBox.getSelectedItem().toString().equalsIgnoreCase("Transfering Activity")){
            statementTransferActivityState="";
            if(jCheckBox1.isSelected())
            {
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"'EXCLUDE TRANSFERING ACTIVITY' WILL BE IGNORED","WARNING !",JOptionPane.WARNING_MESSAGE);

            }
        }
        
        if(isDateChoosen()==true)
        {
            if(startMonthComboBox.getSelectedItem().equals("-- Month --"))
            {
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Report Start Date's Month ","ERROR !",JOptionPane.ERROR_MESSAGE);
                return;
            }
            if(startDayComboBox.getSelectedItem().equals("-- Day --"))
            {
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Report Start Date's Day ","ERROR !",JOptionPane.ERROR_MESSAGE);
                return;
            }
            if(startYearComboBox.getSelectedItem().equals("-- Year --"))
            {
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Report Start Date's Year ","ERROR !",JOptionPane.ERROR_MESSAGE);
                return;
            }
            if(endMonthComboBox.getSelectedItem().equals("-- Month --"))
            {
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Report End Date's Month ","ERROR !",JOptionPane.ERROR_MESSAGE);
                return;
            }
            if(endDayComboBox.getSelectedItem().equals("-- Day --"))
            {
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Report End Date's Day ","ERROR !",JOptionPane.ERROR_MESSAGE);
                return;
            }
            if(endYearComboBox.getSelectedItem().equals("-- Year --"))
            {
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Report End Date's Year ","ERROR !",JOptionPane.ERROR_MESSAGE);
                return;
            }
        useDate="Y";
        startDate=new String(String.valueOf(startYearComboBox.getSelectedItem()).trim()+"-"+systems.getMonthDigit(String.valueOf(startMonthComboBox.getSelectedItem()).trim())+"-"+
                            String.valueOf(startDayComboBox.getSelectedItem()).trim());
        endDate=new String(String.valueOf(endYearComboBox.getSelectedItem()).trim()+"-"+systems.getMonthDigit(String.valueOf(endMonthComboBox.getSelectedItem()).trim())+"-"+
                            String.valueOf(endDayComboBox.getSelectedItem()).trim());
        statementStartDate=startDate;
        statementEndDate=endDate;
        }

        if(itemName_A.equalsIgnoreCase("-- Item Name --")==false && useDate=="N")
        {
            currentTitle="::. View Debit Report [SORT::SINGLE, ENTITY::ITEM, PERIOD::ALL]";
            this.setTitle("::. View Debit Report [SORT::SINGLE, ENTITY::ITEM, PERIOD::ALL]");
            statementType="ITEM_N";

            statementItemName=itemName_A;
            String itemCode=systems.getValue(OpenMSApp.Database_A, "Select * from item where vName='"+itemName_A+"'", 1);

            System.out.println("sort by item , date=n");

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select distinct debitOrder.cDebitOrderCode from debitorder JOIN debitordersummary on debitOrder.cDebitOrderCode=debitOrderSummary.cDebitOrderCode where debitOrder.cStatus='posted' and cItemCode='"+itemCode+"'"+statementTransferActivityState+"",1);

            int xi=0;
            int yi=dbOrderCode.length;

            if(xi<yi)
            {
                System.out.println(itemCode+" - "+dbOrderCode[0]);
                dbAccountCode=new String[yi];
                dbDebitCode=new String[yi];
                dbPostDate=new String[yi];
                dbOrderBy=new String[yi];
                dbOrderDate=new String[yi];
                dbAmount=new String[yi];
                while(xi<yi)
                {
                    dbAccountCode[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",3);
                    dbDebitCode[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",4);
                    dbPostDate[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",5);
                    dbOrderBy[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",6);
                    dbOrderDate[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",7);
                    dbAmount[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",14);
                    systems.freeHeap();
                xi++;
                if(xi==yi){break;}
                }
            }
        }

        if(itemName_A.equalsIgnoreCase("-- Item Name --")==false && useDate=="Y")
        {
            currentTitle="::. View Debit Report [SORT::SINGLE, ENTITY::ITEM, PERIOD::"+startDate+" TO "+endDate+"]";
            this.setTitle("::. View Debit Report [SORT::SINGLE, ENTITY::ITEM, PERIOD::"+startDate+" TO "+endDate+"]");
            statementType="ITEM_Y";

            statementItemName=itemName_A;
            String itemCode=systems.getValue(OpenMSApp.Database_A, "Select * from item where vName='"+itemName_A+"'", 1);

            System.out.println("sort by item , date=y");

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select distinct debitOrder.cDebitOrderCode from debitorder JOIN debitordersummary on debitOrder.cDebitOrderCode=debitOrderSummary.cDebitOrderCode where debitOrder.cStatus='posted' and cItemCode='"+itemCode+"'"+
                    " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'"+statementTransferActivityState,1);
            int xi=0;
            int yi=dbOrderCode.length;

            if(xi<yi)
            {
                dbAccountCode=new String[yi];
                dbDebitCode=new String[yi];
                dbPostDate=new String[yi];
                dbOrderBy=new String[yi];
                dbOrderDate=new String[yi];
                dbAmount=new String[yi];

                while(xi<yi)
                {
                    dbAccountCode[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",3);
                    dbDebitCode[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",4);
                    dbPostDate[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",5);
                    dbOrderBy[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",6);
                    dbOrderDate[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",7);
                    dbAmount[xi]=systems.getValue(OpenMSApp.Database_A, "select * from debitOrder where cDebitOrderCode='"+dbOrderCode[xi]+"'",14);
                    systems.freeHeap();
                xi++;
                if(xi==yi){break;}
                }
            }
        }

        if(merchantID_A.equalsIgnoreCase("-- Merchant ID --")==false && useDate=="N")
        {
            currentTitle="::. View Debit Report [SORT::SINGLE, ENTITY::MERCHANT, PERIOD::ALL]";
            this.setTitle("::. View Debit Report [SORT::SINGLE, ENTITY::MERCHANT, PERIOD::ALL]");
            statementType="MERCHANT_N";
            statementMerchantID=jMerchantIDComboBox.getSelectedItem().toString().trim();

            System.out.println("sort by merchant , date=n");
            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",14);
        }
        if(accountName_A.equalsIgnoreCase("-- Account Name --")==false && useDate=="N")
        {
            currentTitle="::. View Debit Report [SORT::SINGLE, ENTITY::ACCOUNT, PERIOD::ALL]";
            this.setTitle("::. View Debit Report [SORT::SINGLE, ENTITY::ACCOUNT, PERIOD::ALL]");
            statementType="ACCOUNT_N";
            statementAccountName=accountName_A;
            statementAccountUnit=systems.getValue(OpenMSApp.Database_A, "Select * from Account  Where vAccountName='"+accountName_A+"'","vAccountUnit");

            System.out.println("sort by account , date=n");
            String accountCode_A=systems.getValue(OpenMSApp.Database_A, "Select * from Account Where vAccountName='"+accountName_A+"'","cAccountCode");

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+"",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+"",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+"",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+"",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+"", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+"",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+"",14);
        }
        if(userID_A.equalsIgnoreCase("-- User ID --")==false && useDate=="N")
        {
            currentTitle="::. View Debit Report [SORT::SINGLE, ENTITY::USER, PERIOD::ALL]";
            this.setTitle("::. View Debit Report [SORT::SINGLE, ENTITY::USER, PERIOD::ALL]");
            statementType="USER_N";
            statementMerchantID=jMerchantIDComboBox.getSelectedItem().toString().trim();

            System.out.println("sort by merchant , date=n");
            String dbOrderRecord[][]=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cOrderByID='"+userID_A+"'"+statementTransferActivityState+"",1,3,4,5,6,7,14);
//            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",1);
//            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",3);
//            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",4);
//            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",5);
//            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"", 6);
//            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",7);
//            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+"",14);
            dbOrderCode=dbOrderRecord[0];
            dbAccountCode=dbOrderRecord[1];
            dbDebitCode=dbOrderRecord[2];
            dbPostDate=dbOrderRecord[3];
            dbOrderBy=dbOrderRecord[4];
            dbOrderDate=dbOrderRecord[5];
            dbAmount=dbOrderRecord[6];
        }
        if(userID_A.equalsIgnoreCase("-- User ID --")==false && useDate=="Y")
        {
            currentTitle="::. View Debit Report [SORT::SINGLE, ENTITY::USER, PERIOD::"+startDate+" TO "+endDate+"]";
            this.setTitle("::. View Debit Report [SORT::SINGLE, ENTITY::USER, PERIOD::"+startDate+" TO "+endDate+"]");
            statementType="USER_Y";
            statementMerchantID=jMerchantIDComboBox.getSelectedItem().toString().trim();

            String dbOrderRecord[][]=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cOrderbyID='"+userID_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",1,3,4,5,6,7,14);
//            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
//                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",1);
//            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
//                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",3);
//            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
//                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",4);
//            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
//                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",5);
//            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
//                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'", 6);
//            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
//                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",7);
//            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
//                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",14);
            dbOrderCode=dbOrderRecord[0];
            dbAccountCode=dbOrderRecord[1];
            dbDebitCode=dbOrderRecord[2];
            dbPostDate=dbOrderRecord[3];
            dbOrderBy=dbOrderRecord[4];
            dbOrderDate=dbOrderRecord[5];
            dbAmount=dbOrderRecord[6];
        }
        if(accountName_A.equalsIgnoreCase("-- Account Name --")==false && useDate=="Y")
        {
            currentTitle="::. View Debit Report [SORT::SINGLE, ENTITY::ACCOUNT, PERIOD::"+startDate+" TO "+endDate+"]";
            this.setTitle("::. View Debit Report [SORT::SINGLE, ENTITY::ACCOUNT, PERIOD::"+startDate+" TO "+endDate+"]");
            statementType="ACCOUNT_Y";
            statementAccountName=accountName_A;
            statementAccountUnit=systems.getValue(OpenMSApp.Database_A, "Select * from Account  Where vAccountName='"+accountName_A+"'","vAccountUnit");

            String accountCode_A=systems.getValue(OpenMSApp.Database_A, "Select * from Account Where vAccountName='"+accountName_A+"'","cAccountCode");

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cAccountCode='"+accountCode_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",14);
        }
        if(merchantID_A.equalsIgnoreCase("-- Merchant ID --")==false && useDate=="Y")
        {
            currentTitle="::. View Debit Report [SORT::SINGLE, ENTITY::MERCHANT, PERIOD::"+startDate+" TO "+endDate+"]";
            this.setTitle("::. View Debit Report [SORT::SINGLE, ENTITY::MERCHANT, PERIOD::"+startDate+" TO "+endDate+"]");
            statementType="MERCHANT_Y";
            statementMerchantID=jMerchantIDComboBox.getSelectedItem().toString().trim();

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cMerchantID='"+merchantID_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",14);
        }
        if(activity_A.equalsIgnoreCase("-- Cash Outflow Activity --")==false && useDate=="N")
        {
            currentTitle="::. View Debit Report [SORT::SINGLE, ENTITY::CASH OUTFLOW ACTIVITY, PERIOD::ALL]";
            this.setTitle("::. View Debit Report [SORT::SINGLE, ENTITY::CASH OUTFLOW ACTIVITY, PERIOD::ALL]");
            statementType="ACTIVITY_N";
            statementActivity=jActivityComboBox.getSelectedItem().toString().trim();

            System.out.println("sort by activity , date=n");
            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+"",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+"",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+"",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+"",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+"", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+"",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+"",14);
        }
        if(activity_A.equalsIgnoreCase("-- Cash Outflow Activity --")==false && useDate=="Y")
        {
            currentTitle="::. View Debit Report [SORT::SINGLE, ENTITY::CASH OUTFLOW ACTIVITY, PERIOD::"+startDate+" TO "+endDate+"]";
            this.setTitle("::. View Debit Report [SORT::SINGLE, ENTITY::CASH OUTFLOW ACTIVITY, PERIOD::"+startDate+" TO "+endDate+"]");
            statementType="ACTIVITY_Y";
            statementActivity=jActivityComboBox.getSelectedItem().toString().trim();

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted' and cActivity='"+activity_A+"'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",14);
        }
        if(merchantID_A.equalsIgnoreCase("-- Merchant ID --")==true &&userID_A.equalsIgnoreCase("-- User ID --")==true && itemName_A.equalsIgnoreCase("-- Item Name --") && activity_A.equalsIgnoreCase("-- Cash Outflow Activity --") && accountName_A.equalsIgnoreCase("-- Account Name --")==true && useDate=="Y")
        {
            currentTitle="::. View Debit Report [SORT::FULL, GROUPING ENTITY::NONE, PERIOD::"+startDate+" TO "+endDate+"]";
            this.setTitle("::. View Debit Report [SORT::FULL, GROUPING ENTITY::NONE, PERIOD::"+startDate+" TO "+endDate+"]");
            statementType="FULL_Y";

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59'",14);
        }
        if(merchantID_A.equalsIgnoreCase("-- Merchant ID --")==true &&userID_A.equalsIgnoreCase("-- User ID --")==true && itemName_A.equalsIgnoreCase("-- Item Name --") && activity_A.equalsIgnoreCase("-- Cash Outflow Activity --") && accountName_A.equalsIgnoreCase("-- Account Name --")==true && useDate=="N")
        {
            currentTitle="::. View Debit Report [SORT::FULL, GROUPING ENTITY::NONE, PERIOD::ALL]";
            this.setTitle("::. View Debit Report [SORT::FULL, GROUPING ENTITY::NONE, PERIOD::ALL]");
            statementType="FULL_N";

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+"",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+"",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+"",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+"",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+"", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+"",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+"",14);
        }

        /*
         * *
         */

        if(jAccountRadioButton.isSelected() && jAccountNameComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Account Name --") && useDate=="Y" && jCheckBox2.isSelected())
        {
            currentTitle="::. View Debit Report [SORT::FULL, GROUPING ENTITY::ACCOUNT, PERIOD::"+startDate+" TO "+endDate+"]";
            this.setTitle("::. View Debit Report [SORT::FULL, GROUPING ENTITY::ACCOUNT, PERIOD::"+startDate+" TO "+endDate+"]");
            statementType="FULL_ACCOUNT_Y";

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",14);
        }
        if(jAccountRadioButton.isSelected() && jAccountNameComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Account Name --") && useDate=="N" && jCheckBox2.isSelected())
        {
            currentTitle="::. View Debit Report [SORT::FULL, GROUPING ENTITY::ACCOUNT, PERIOD::ALL";
            this.setTitle("::. View Debit Report [SORT::FULL, GROUPING ENTITY::ACCOUNT, PERIOD::ALL");
            statementType="FULL_ACCOUNT_N";

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",14);
        }
        /*
         * *
         */
        if(jMerchantRadioButton.isSelected() && jMerchantIDComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Merchant ID --") && useDate=="Y" && jCheckBox2.isSelected())
        {
            currentTitle="::. View Debit Report [SORT::FULL, GROUPING ENTITY::MERCHANT, PERIOD::"+startDate+" TO "+endDate+"]";
            this.setTitle("::. View Debit Report [SORT::FULL, GROUPING ENTITY::MERCHANT, PERIOD::"+startDate+" TO "+endDate+"]");
            statementType="FULL_MERCHANT_Y";

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cMerchantID",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cMerchantID",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cMerchantID",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cMerchantID",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cMerchantID", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cMerchantID",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cMerchantID",14);
        }
        if(jMerchantRadioButton.isSelected() && jMerchantIDComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Merchant ID --") && useDate=="N" && jCheckBox2.isSelected())
        {
            currentTitle="::. View Debit Report [SORT::FULL, GROUPING ENTITY::MERCHANT, PERIOD::ALL]";
            this.setTitle("::. View Debit Report [SORT::FULL, GROUPING ENTITY::MERCHANT, PERIOD::ALL]");
            statementType="FULL_MERCHANT_N";

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cMerchantID",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cMerchantID",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cMerchantID",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cMerchantID",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cMerchantID", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cMerchantID",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cMerchantID",14);
        }

        /*
         * *
         */

        if(jActivityRadioButton.isSelected() && jActivityComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Cash Outflow Activity --") && useDate=="Y" && jCheckBox2.isSelected())
        {
            currentTitle="::. View Debit Report [SORT::FULL, GROUPING ENTITY::CASH OUTFLOW ACTIVITY, PERIOD::"+startDate+" TO "+endDate+"]";
            this.setTitle("::. View Debit Report [SORT::FULL, GROUPING ENTITY::CASH OUTFLOW ACTIVITY, PERIOD::"+startDate+" TO "+endDate+"]");
            statementType="FULL_ACTIVITY_Y";

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+""+
                     " AND debitOrder.dOrderDate BETWEEN '"+startDate+"  00:00:00' AND '"+endDate+" 23:59:59' order by cAccountCode",14);
        }
        if(jActivityRadioButton.isSelected() && jActivityComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Cash Outflow Activity --") && useDate=="N" && jCheckBox2.isSelected())
        {
            currentTitle="::. View Debit Report [SORT::FULL, GROUPING ENTITY::CASH OUTFLOW ACTIVITY, PERIOD::ALL";
            this.setTitle("::. View Debit Report [SORT::FULL, GROUPING ENTITY::CASH OUTFLOW ACTIVITY, PERIOD::ALL");
            statementType="FULL_ACTIVITY_N";

            dbOrderCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",1);
            dbAccountCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",3);
            dbDebitCode=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",4);
            dbPostDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",5);
            dbOrderBy=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode", 6);
            dbOrderDate=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",7);
            dbAmount=systems.getColumn(OpenMSApp.Database_A, "select * from debitOrder where cStatus='posted'"+statementTransferActivityState+" order by cAccountCode",14);
        }
        /*
         * *
         */

        int x=0;
        int y=dbOrderCode.length;

        tableObject=new Object[y][9];

        while(x<y)
        {
            String accountCurrency=systems.getValue(OpenMSApp.Database_A, "Select * from Account Where cAccountCode='"+dbAccountCode[x]+"'", "vAccountUnit");
            String empCode=systems.getValue(OpenMSApp.Database_A, "Select * from Login Where cLoginCode='"+dbOrderBy[x]+"'", "cEmployeeID");
            String empName=systems.getValue(OpenMSApp.Database_A,"Select * from Employee where cEmployeeID= '"+empCode+"'","vFirstName").trim()+" "+
                    systems.getValue(OpenMSApp.Database_A,"Select * from Employee where cEmployeeID= '"+empCode+"'","vMiddleName").trim()+" "+
                    systems.getValue(OpenMSApp.Database_A,"Select * from Employee where cEmployeeID= '"+empCode+"'","vlastName").trim();
            tableObject[x][0]=x+1;
            tableObject[x][1]=empName;
            tableObject[x][2]=dbOrderCode[x].trim();
            tableObject[x][3]=dbOrderDate[x].trim();
            tableObject[x][4]=dbDebitCode[x].trim();
            tableObject[x][5]=dbPostDate[x].trim();
            try
            {
                tableObject[x][6]=systems.converToRealMoneyFormat(dbAmount[x].trim());
            }
            catch(Exception e)
            {
                tableObject[x][6]="Er!M1C01K0";
            }
            tableObject[x][7]=accountCurrency;
            tableObject[x][8]=systems.getValue(OpenMSApp.Database_A, "Select * from DebitOrder where cDebitOrderCode='"+dbOrderCode[x]+"'", "cActivity");
            systems.freeHeap();
            x+=1;
            if(x==y){break;}
       }

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
        tableObject,
            new String [] {
                "S/N", "Order By", "Order Code", "Order Date", "Debit Code", "Debit Date", "Amount", "Currency","Cash Outflow Activity"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.getColumnModel().getColumn(0).setMinWidth(40);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(40);
        jTable1.getColumnModel().getColumn(0).setMaxWidth(40);
        jTable1.getColumnModel().getColumn(1).setPreferredWidth(10);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox endDayComboBox;
    private javax.swing.JComboBox endMonthComboBox;
    private javax.swing.JComboBox endYearComboBox;
    private javax.swing.JComboBox jAccountNameComboBox;
    private javax.swing.JRadioButton jAccountRadioButton;
    private javax.swing.JComboBox jActivityComboBox;
    private javax.swing.JRadioButton jActivityRadioButton;
    private javax.swing.JButton jCancelButton;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JComboBox jItemComboBox;
    private javax.swing.JRadioButton jItemRadioButton;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JComboBox jMerchantIDComboBox;
    private javax.swing.JRadioButton jMerchantRadioButton;
    private javax.swing.JTextField jNameTextField;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton jPreviewButton;
    private javax.swing.JButton jRefreshButton;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JComboBox jUserIDComboBox;
    private javax.swing.JRadioButton jUserIDRadioButton;
    private javax.swing.JTextField jUserTextField;
    private javax.swing.JComboBox startDayComboBox;
    private javax.swing.JComboBox startMonthComboBox;
    private javax.swing.JComboBox startYearComboBox;
    // End of variables declaration//GEN-END:variables

}
